<?php
namespace app\admin\controller;
use app\common\service\Config;


/**
 * @name 配置管理
 * @desc 配置管理
 * @auth true
 * @author: xujianping(814876569@qq.com)
 * @datetime: 2017/9/18 上午 10:37
 */
class SystemSetting extends Common
{

    public $allowField = ['site_name','site_email','site_qq','site_tel','site_copyright','site_address','site_logo','site_contact_us'];
    /**
     * index
     * @author: xujianping(814876569@qq.com)
     * @return mixed
     */
    public function index(){

        $conf = new Config();
        $info = $conf->getMany($this->allowField);

        return view('',['info'=>$info]);
    }

    public function save(){

        if (!$this->request->isPost()){
            $this->error('提交错误');
        }

        $post = $this->request->post();

        $conf = new Config();

        $status = $conf->set($post,$this->allowField);

        if ($status){
            $this->success('更新成功','/admin/system_setting');
        }else{
            $this->error('更新失败');
        }
    }
}